using System;
using System.Collections.Generic;
using Slqj.Common;
using Shc.Sql;
namespace Slqj.Data
{
	[Serializable]
	public class ViewRoomOrderItemReport
		: BaseViewRoomOrderItemReport
	{		
		/// <summary>
        /// 根据条件查询单个实体
        /// </summary>
        /// <returns></returns>
        public static ViewRoomOrderItemReport Find(params Criterion[] criteria)
        {
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                return DbManager.Current.Find<ViewRoomOrderItemReport>(criteria);
            }
        }
		
		/// <summary>
        /// 根据条件查询单个实体
        /// </summary>
        /// <returns></returns>
        public static ViewRoomOrderItemReport Find(DbSession ss,params Criterion[] criteria)
        {
			return DbManager.Current.Find<ViewRoomOrderItemReport>(ss,criteria);
        }

		/// <summary>
        /// 根据主键查询实体
        /// </summary>
		/// <param name="keys"></param>
        /// <returns></returns>
        public static ViewRoomOrderItemReport FindByPK(params object[] keys)
        {
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                return DbManager.Current.FindPK<ViewRoomOrderItemReport>(ss, keys);
            }
        }
		
		/// <summary>
        /// 根据主键查询实体
        /// </summary>
		/// <param name="keys"></param>
        /// <returns></returns>
        public static ViewRoomOrderItemReport FindByPK(DbSession ss,params object[] keys)
        {
            return DbManager.Current.FindPK<ViewRoomOrderItemReport>(ss, keys);
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindAll(Order[] orders, params Criterion[] criteria)
        {
            IList<ViewRoomOrderItemReport> list=new List<ViewRoomOrderItemReport>();
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                DbManager.Current.Query(ss, list, orders, criteria);
                return list;
            }
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindAll(params Criterion[] criteria)
        {
			return FindAll(new Order[0],criteria);
		}
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindAll(Order[] orders,DbSession ss, params Criterion[] criteria)
        {
            IList<ViewRoomOrderItemReport> list=new List<ViewRoomOrderItemReport>();
            
            DbManager.Current.Query(ss, list, orders, criteria);
            return list;
        }
		
		/// <summary>
        /// 根据条件查询
        /// </summary>
		/// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindAll(DbSession ss,params Criterion[] criteria)
        {
			return FindAll(new Order[0],ss,criteria);
		}
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindByPage(int curPage,int pagesize,Order[] orders, 
			params Criterion[] criteria)
        {
            IList<ViewRoomOrderItemReport> list = new List<ViewRoomOrderItemReport>();
            using (DbSession ss = DbManager.Current.OpenSession())
            {
                DbManager.Current.Query(ss,list, curPage, pagesize, orders, criteria);
                return list;
            }
        }
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindByPage(int curPage,int pagesize,params Criterion[] criteria)
        {
			return FindByPage(curPage,pagesize,new Order[0],criteria);
		}
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindByPage(int curPage,int pagesize,Order[] orders, 
			DbSession ss ,params Criterion[] criteria)
        {
            IList<ViewRoomOrderItemReport> list = new List<ViewRoomOrderItemReport>();
            
            DbManager.Current.Query(ss,list, curPage, pagesize, orders, criteria);
            return list;
        }
		
		/// <summary>
        /// 根据条件分页查询
        /// </summary>
        /// <param name="orders"></param>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public static IList<ViewRoomOrderItemReport> FindByPage(int curPage,int pagesize,
			DbSession ss ,params Criterion[] criteria)
        {
			return FindByPage(curPage,pagesize,new Order[0],ss,criteria);
		}

        public string RefundStatus
        {
            get
            {
                return RefundrDate == null ? "否" : "是";
            }
        }

        public string RefundFee
        {
            get
            {
                SystemConfig ticketConfig = SystemConfig.Load("cfg_ticket_refund");
                return RefundrDate == null ? string.Empty : (FieldUI.InFloat(ticketConfig.ConfigValue) * Quantity).ToString("0.00");
            }
        }

	    public int Days
	    {
	        get
	        {
	            return (EndDate - this.StartDate).Days;
	        }
	    }

	    public int AvgAmount
	    {
	        get
	        {
                return Convert.ToInt32(TotalAmount / Days);
	        }
	    }

	    public double SystemTotalAmount
	    {
	        get
	        {
	            return SystemProfit*Quantity;
	        }
	    }

        public double MemberSaleAmount
        {
            get; set;
        }

       
	}
}
